package com.buaat.platform.resources.user;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.buaat.platform.repository.user.User;
import com.buaat.platform.repository.user.UserRepository;

@RestController
@RequestMapping("/users")
public class UsersResources {

	@Autowired
	private UserRepository userRepository;

	private static final Logger log = LoggerFactory
			.getLogger(UsersResources.class);

	@RequestMapping(value = "/{pageNum}/{pageSize}", method = RequestMethod.GET)
	public List<User> get(@PathVariable Integer pageNum,
			@PathVariable Integer pageSize) {
		log.info("pageNum:" + pageNum + " pageSize:" + pageSize);
		return userRepository.findByUsername("何智晖", new PageRequest(pageNum,
				pageSize));
	}
}
